home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource3 / 126_01 / dmap.c < prev    next >
Text File  |  1985-03-11  |  2KB  |  90 lines

  1. #include <bdscio.h>
  2. #include "bdscio+.h"
  3.  
  4. #define NIOBUFS 1
  5. #include <fio1.h>
  6.  
  7. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  8. main(argc,argv)
  9.     int argc;
  10.     char **argv;
  11.     {
  12.     FILE *fp;
  13.     char name[FILENAME], *pfcb;
  14.     unsigned size;
  15.     int i, extents;
  16. #include <fio2.h>
  17.  
  18.     fp = 0;
  19.     if (argc EQ 2) {
  20.         if (badname(argv[1])) exit(0);
  21.         fp = fopen(argv[1], "r");
  22.         if (!fp) printf("Can't find %s.\n");
  23.     }
  24.     if (!fp) fp = goodfile("Filename? ", name);
  25.     size = filesize(fp);
  26.     extents = (size/128); /* 128 records/extent */
  27.     if (size%128) extents++;
  28.     printf("File size is %u records, thus %d extents.\n",
  29.         size, extents);
  30.     pfcb = fcbaddr(fp->_fd);
  31.     for (i=0; i<extents; i++) {
  32.         seek(fp->_fd, 128*i, 0);
  33.         bdos(33, pfcb);
  34.         showfcb(pfcb);
  35.     }
  36. }
  37. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  38. showfcb(f)
  39.     char *f; /* POINTER TO FCB */
  40.     {
  41.     int i, *b, mt;
  42.  
  43.         printf("  ");
  44.         for(i=1; i <= 11; i++) {
  45.             if (f[i] & 128) printf("!");
  46.             else printf(" ");
  47.         }
  48.         printf("<-- HIGH BITS SET\n");
  49.  
  50.     printf("%d ",f[0]);
  51.     for(i=1; i <= 11; i++)
  52.         printf("%c",f[i]);
  53.     printf(" Ex%d %d %d RC%3d ",f[12], f[13], f[14], f[15]);
  54.     printf("B");
  55.     b = &f[16];
  56.     for (i=0; i <=7 ; i++)
  57.         printf("%3d/",b[i]);
  58.     printf(" %3d %3d %3d", f[33], f[34], f[35]);
  59.     printf("\n");
  60. }
  61. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  62. filesize(fp)
  63.     FILE *fp;
  64.     {
  65.  
  66. /* FILE MUST BE OPEN FOR READING BEFORE CALLING filesize() */
  67. /* filesize() returns the CP/M record count (128 bytes/record) */
  68. /* variable receiving the record count should be unsigned int */
  69.  
  70.     char *fcb;
  71.     unsigned *pu;
  72.  
  73.     fcb = fcbaddr(fp->_fd); /* GET POINTER TO FILE CONTROL BLOCK */
  74.     bdos(35,fcb); /* INSTALL RECORD COUNT IN FILE CONTROL BLOCK */
  75.  
  76.     if (*(fcb+35) == 1) {
  77.         printf("FATAL ERROR in filesize():\n");
  78.         printf("RECORD COUNT IS 65536;\n");
  79.         exit(0);
  80.     }
  81.  
  82.     /* GET COUNT OF FILLED SECTORS WRITTEN = TOTAL SECTORS - 1 */
  83.     pu = fcb+33;
  84.     return(*pu);
  85. }
  86. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  87. #include <fio3.h>
  88. i++)
  89.         printf("%c",f[i]);
  90.